package com.ababa.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class RestResponse<T> implements Serializable {

    private int code;
    private String message;
    private T data;

    public RestResponse<T> success(int code, String msg, T data){
        this.code = code;
        this.message = msg;
        this.data = data;
        return this;
    }

    public RestResponse<T> success(String msg, T data){
        return success(200, msg,data);
    }

    public RestResponse<T> success(T data){
        return success(200, "success", data);
    }

    public RestResponse<T> error(int code, String msg, T data){
        this.code = code;
        this.message = msg;
        this.data = data;
        return this;
    }

    public RestResponse<T> error(String msg, T data){
        return error(400, msg, data);
    }

}
